/**
 * Copyright 2024 NoEvaa
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#define AYMMAP_VERSION "0.0.0"

#include <cstdint>
#include <type_traits>
#include <filesystem>

#include "aymmap/config.hpp"
#include "aymmap/log.hpp"
#include "aymmap/detail/errno.hpp"
#include "aymmap/detail/enum.hpp"

#if defined(_AYMMAP_CFG_EN_ASSERT) && defined(_DEBUG)
#include <cassert>
#define AYMMAP_ASSERT(...) assert(__VA_ARGS__)
#else
#define AYMMAP_ASSERT(...) static_cast<void>(0)
#endif

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__NT__)
#define _AYMMAP_WIN
#endif

#define _AYMMAP_DISABLE_CLASS_COPY(_class)                                                         \
    _class(_class const &) = delete;                                                               \
    _class & operator=(_class const &) = delete;

namespace aymmap {
namespace fs = std::filesystem;

enum class AccessFlag : std::uint32_t {
    kRead   = 0x0001,
    _kWrite = 0x0002,
    kWrite  = _kWrite | kRead,
    kCopy   = 0x0004,
    kExec   = 0x0008,
    kCreate = 0x0010,
    _kResize = 0x0020,
    kResize  = _kResize | _kWrite,
    kNoAccess = 0x0040,

    kDefault   = kWrite | kCreate,
    kReadOnly  = kRead,
    kReadWrite = kWrite,
    kWriteCopy = kWrite | kCopy,
    kReadExec  = kRead | kExec,
};

enum class FLockFlag : std::int8_t {
    kShared      = 0x01,
    kExclusive   = 0x02,
    kNonBlocking = 0x04,
    kUnlock      = 0x08,

    kSH = kShared,
    kEX = kExclusive,
    kNB = kNonBlocking,
    kUN = kUnlock,
    kNBSH = kSH | kNB,
    kNBEX = kEX | kNB,
};

enum class AdviceFlag {
    kNormal = 0,
    kRandom,
    kSequential,
    kWillNeed,
    kDontNeed,
};

enum class BufferPos {
    kBeg = 0,
    kEnd,
    kCur
};
}

